using MOKA.TPM.Utility.Const;
using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace MOKA.TPM.Entity;

/// <summary>
/// 调拨主表
/// </summary>
[Tenant(TPMConst.TPMConfigId)]
[SugarTable("PartMoveM", "调拨主表")]
public class PartMoveM
{
    /// <summary>
    /// 调拨单号
    /// </summary>
    [SugarColumn(ColumnName = "BillNo", ColumnDescription = "调拨单号", Length = 50, IsPrimaryKey = true)]
    [Required, MaxLength(50)]
    public string BillNo { get; set; } = string.Empty;

    /// <summary>
    /// 调拨类型
    /// </summary>
    [SugarColumn(ColumnName = "MoveType", ColumnDescription = "调拨类型")]
    public Guid MoveType { get; set; }

    /// <summary>
    /// 调拨状态
    /// </summary>
    [SugarColumn(ColumnName = "MoveStatus", ColumnDescription = "调拨状态")]
    public Guid MoveStatus { get; set; }

    /// <summary>
    /// 调拨时间
    /// </summary>
    [SugarColumn(ColumnName = "MoveTime", ColumnDescription = "调拨时间")]
    public DateTime MoveTime { get; set; }

    /// <summary>
    /// 原车间
    /// </summary>
    [SugarColumn(ColumnName = "Workshop", ColumnDescription = "原车间")]
    public Guid Workshop { get; set; }

    /// <summary>
    /// 到车间
    /// </summary>
    [SugarColumn(ColumnName = "To_WorkShop", ColumnDescription = "到车间")]
    public Guid ToWorkShop { get; set; }

    /// <summary>
    /// 确认人
    /// </summary>
    [SugarColumn(ColumnName = "ConMan", ColumnDescription = "确认人", Length = 50)]
    [MaxLength(50)]
    public string? ConMan { get; set; }

    /// <summary>
    /// 确认人姓名
    /// </summary>
    [SugarColumn(ColumnName = "ConManName", ColumnDescription = "确认人姓名", Length = 50)]
    [MaxLength(50)]
    public string? ConManName { get; set; }

    /// <summary>
    /// 确认时间
    /// </summary>
    [SugarColumn(ColumnName = "ConTime", ColumnDescription = "确认时间")]
    public DateTime? ConTime { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [SugarColumn(ColumnName = "Remark", ColumnDescription = "备注", Length = 200)]
    [MaxLength(200)]
    public string? Remark { get; set; }

    /// <summary>
    /// 创建人
    /// </summary>
    [SugarColumn(ColumnName = "CreateUser", ColumnDescription = "创建人", Length = 20)]
    [Required, MaxLength(20)]
    public string CreateUser { get; set; } = string.Empty;

    /// <summary>
    /// 创建时间
    /// </summary>
    [SugarColumn(ColumnName = "CreateTime", ColumnDescription = "创建时间")]
    public DateTime CreateTime { get; set; }

    /// <summary>
    /// 修改人
    /// </summary>
    [SugarColumn(ColumnName = "UpdateUser", ColumnDescription = "修改人", Length = 20)]
    [MaxLength(20)]
    public string? UpdateUser { get; set; }

    /// <summary>
    /// 修改时间
    /// </summary>
    [SugarColumn(ColumnName = "UpdateTime", ColumnDescription = "修改时间")]
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// MoveStatus (调拨状态) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(MoveStatus),nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_MoveStatus { get; set; }

    /// <summary>
    /// MoveType (调拨类型) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(MoveType),nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_MoveType { get; set; }

    /// <summary>
    /// To_WorkShop (到车间) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(ToWorkShop),nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_To_WorkShop { get; set; }

    /// <summary>
    /// Workshop (原车间) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Workshop),nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_Workshop { get; set; }

    /// <summary>
    /// CreateUser (创建人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CreateUser),nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_CreateUser { get; set; }

    /// <summary>
    /// UpdateUser (修改人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(UpdateUser),nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_UpdateUser { get; set; }

    /// <summary>
    /// 子表：调拨明细
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(PartMoveD.BillNo))]//一对多
    public List<PartMoveD> PartMoveDs { get; set; }
}